/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#include "StdAfx.h"
#include ".\mhelpinfo.h"

#include "shellapi.h"

//---------------------------------------------------------------------------

MHelpInfo::MHelpInfo(void)
{
	applicationPath.Empty();
}

MHelpInfo::~MHelpInfo(void)
{
}

//---------------------------------------------------------------------------

bool MHelpInfo::OpenHtmlFile(CString fileNameIn)
{
	CString strFile;
	CString strFolder;
	HINSTANCE retVal;

	strFolder  = applicationPath;
	strFolder += _T("Help\\");

	strFile  = strFolder;
	strFile += fileNameIn;

	retVal = ShellExecute(NULL, NULL, strFile, NULL, strFolder, SW_SHOW);

	return (retVal > (HINSTANCE)32) ? true : false;
}

//---------------------------------------------------------------------------

CString MHelpInfo::GetFileNameById(int helpIdIn)
{
	CString str;

	switch(helpIdIn){
		case HELPID_INDEX :
			str = _T("index.html");
			break;

		case HELPID_DLG_MAIN :
			str = _T("dlgMain.html");
			break;

		case HELPID_DLG_MAP :
			str = _T("dlgMap.html");
			break;

		case HELPID_DLG_DET :
			str = _T("dlgDetails.html");
			break;

		case HELPID_DLG_MSG :
			str = _T("dlgMessages.html");
			break;

		case HELPID_DLG_SCANSEL :
			str = _T("dlgSelect.html");
			break;

		case HELPID_DLG_SCANCFG :
			str = _T("dlgScanCfg.html");
			break;
		case HELPID_DLG_SCANCFG_ASH :
			str = _T("addrSpec.html");
			break;

		case HELPID_DLG_SCANJOB :
			str = _T("dlgJob.html");
			break;

		case HELPID_DLG_INTF :
			str = _T("dlgInftSel.html");
			break;

		case HELPID_DLG_CONFIG :
			str = _T("dlgConfig.html");
			break;

		case HELPID_DLG_WMISEL :
			str = _T("dlgBuildWMI.html");
			break;

		case HELPID_DLG_BLDWOL :
			str = _T("dlgBuildWOL.html");
			break;

		case HELPID_DLG_BLDSHUTDOWN :
			str = _T("dlgBuildShutdown.html");
			break;

		case HELPID_DLG_HUNT :
			str = _T("dlgHunt.html");
			break;

		case HELPID_EDIT_MACLOOKUP :
//			str = _T("tools.html#macLookup");
			str = _T("tools.html");
			break;

		case HELPID_EDIT_MCAST4LOOK :
//			str = _T("tools.html#mcast4Lookup");
			str = _T("tools.html");
			break;

		default:
			str = _T("index.html");
			break;
	}

	return str;
}

//---------------------------------------------------------------------------

bool MHelpInfo::ShowHelp(int helpIdIn)
{
	CString str;

	str = GetFileNameById(helpIdIn);

	return OpenHtmlFile(str);
}

//---------------------------------------------------------------------------

bool MHelpInfo::OpenGPL(void)
{
	CString strFile;
	CString strFolder;
	HINSTANCE retVal;

	strFolder  = applicationPath;

	strFile  = strFolder;
	strFile += _T("COPYING.txt");

	retVal = ShellExecute(NULL, NULL, strFile, NULL, strFolder, SW_SHOW);

	return (retVal > (HINSTANCE)32) ? true : false;
}

//---------------------------------------------------------------------------
